package com.pinyougou.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.pinyougou.pojo.TbBrand;
import com.pinyougou.sellergoods.service.IBrandService;
import entity.PageResult;
import entity.Result;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/brand")
public class BrandController {
    /*一行Damaa*/
    @Reference
    private IBrandService brandService;

    @RequestMapping("/findAll")
    public List<TbBrand> getAll() {
        return brandService.findAll();
    }

    @RequestMapping("/findList")
    public List<Map> findList() {
        return brandService.findList();
    }

    @RequestMapping("/findByPagination")
    public PageResult findByPagination(@RequestParam(name = "pageNum",defaultValue = "1") int pageNum,
                                       @RequestParam(name = "pageSize",defaultValue = "10") int pageSize,
                                       @RequestParam("name") String name) {
        return brandService.findByPagination(pageNum,pageSize,name);
    }

    @RequestMapping("/addTbBrand")
    public Result addTbBrand(@RequestBody TbBrand brand) {
        return brandService.addTbBrand(brand);
    }

    @RequestMapping("/getById")
    public Result getById (Long id) {
        return brandService.getById(id);
    }

    @RequestMapping("/updTbBrand")
    public Result updTbBrand(@RequestBody TbBrand brand) {
        return brandService.updTbBrand(brand);
    }

    @RequestMapping("/delByIds")
    public Result delByIds(Long[] idList) {
        return brandService.delById(idList);
    }
}
